package argirithm;


import java.util.Arrays;
import java.util.Random;

public class Demo07 {
    public static void main(String[] args) {
        long[] arr = new long[5000000];
        long[] top5 = new long[100];
        Random random = new Random();
        for (int i = 0; i <arr.length ; i++) {
            arr[i] = random.nextInt(50000000);
            long num = arr[i];
            int index = Arrays.binarySearch(top5,num);
            if (index==0 || index==-1){
                continue;
            }
            if (index<0){
                index = -(index+1);
            }
            for (int j = 1; j <index ; j++) {
                top5[j-1]=top5[j];
            }
            top5[index-1]=num;
        }
        for (long a :top5
             ) {
            System.out.println(a);
        }
        }
    }

